﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Payroll.BusinessLogic.Messages;
using PayrollHR.Web;

namespace PayrollHR.Administration.Modules
{
    public partial class EmailInfo : BasePayrollAdministrationUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            { 
                
            }
        }        
        public void Bind(EmailAccounts e)
        {
            hfEmailAccountId.Value = e.EmailAccountId.ToString();
            txtEmail.Text = e.Email;
            txtDisplayName.Text = e.DisplayName;
            txthost.Text = e.Host;
            txtPort.Text = e.Port.ToString();
            txtUserName.Text = e.Username;
            txtpass.Text = e.Password;
            cCre.Checked = e.UseDefaultCredentials;
            cssl.Checked = e.EnableSSL;
            pass.Value = e.Password;    
        }
        public EmailAccounts GetEmail()
        {
            EmailAccounts email = new EmailAccounts
            {
                EmailAccountId = Convert.ToInt32(hfEmailAccountId.Value),
                Email = txtEmail.Text,
                DisplayName = txtDisplayName.Text,
                Host = txthost.Text,
                Port = Convert.ToInt32(txtPort.Text),
                Username = txtUserName.Text,
                Password = txtpass.Text,
                UseDefaultCredentials = cCre.Checked,
                EnableSSL = cssl.Checked
            };
            return email;
        }
    }
}